package com.example.springbootdemo.scanner;

import com.example.springbootdemo.scanner.custompkg.Test;
import com.example.springbootdemo.scanner.custompkg.TestNotAnno;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Import;

@SpringBootApplication
@Import(CustomImportBeanDefinitionRegister.class)
public class ScannerDemo {

    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(ScannerDemo.class, args);

        Test test = (Test) applicationContext.getBean("test");
        test.test();

        try {
            TestNotAnno testNotAnno = (TestNotAnno) applicationContext.getBean("testNotAnno");
            testNotAnno.test();
        } catch (Exception e) {
            System.out.println("TestNotAnno没有被@CustomAnno注解");
        }
    }
}
